import BundleMgr from "./BundleMgr"

/**
 * UI管理类
 */
export default class UiMgr {
    private static _instance: UiMgr = null
    public static get instance() {
        if (!this._instance) {
            this._instance = new UiMgr()
        }
        return this._instance
    }

    /**
     * 添加UI
     * @param bundleName 包名
     * @param prefabName 预制名
     */
    async addUI(bundleName: string, prefabName: string) {
        // 获取预制
        let prefab = await BundleMgr.instance.getPrefab(bundleName, prefabName)
        // 实例化节点
        let node = cc.instantiate(prefab)
        // 添加到场景
        cc.director.getScene().getChildByName('Canvas').addChild(node)
    }
}
